package com.soap.utils;

import com.alibaba.fastjson.JSONObject;
import com.soap.commons.RedisKeys;
import com.soap.entity.po.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import redis.clients.jedis.JedisPool;


/**
 * 通过token获取用户
 */
@Component
public class UserRedisUtils {

    @Autowired
    private JedisTools jedisTools;


    /**
     * 通过 Token获取Person
     * @param token
     * @return
     */
    public Person getPersonWithToken(String token) {
        String userString = jedisTools.get(RedisKeys.LOGIN_INFO + token);
        Person person = JSONObject.parseObject(userString, Person.class);
        return person;
    }

}
